set_param ips.useCIPSv3 1
file mkdir build 
cd build
source ../xsa_scripts/project.tcl
source ../xsa_scripts/dr.bd.tcl
source ../xsa_scripts/pfm_decls.tcl
import_files -fileset utils_1 -norecurse ./../data/qor_scripts/prohibit_select_bli_bels_for_hold.tcl
set_property platform.run.steps.place_design.tcl.pre [get_files prohibit_select_bli_bels_for_hold.tcl] [current_project]

set pre_synth ""

if { $argc > 1} {
  set pre_synth [lindex $argv 2]
}
#Pre_synth Platform Flow
if {$pre_synth} {
  set_property platform.platform_state "pre_synth" [current_project]
  write_hw_platform -force $PLATFORM_NAME.xsa
  validate_hw_platform $PLATFORM_NAME.xsa -verbose 
} else {
  #Post_implememtation Platform
  set_property generate_synth_checkpoint true [get_files -norecurse *.bd]
  #Importing Placement Files
  
  # Synthesis Run
  launch_runs synth_1 -jobs 20
  wait_on_run synth_1
  #Implementation Run
  launch_runs impl_1 -to_step write_device_image
  wait_on_run impl_1

  open_run impl_1
  # Generating XSA
  write_hw_platform -force -include_bit $PLATFORM_NAME.xsa
  validate_hw_platform $PLATFORM_NAME.xsa -verbose
}
#generate README.hw
set board vmk180

set fd [open README.hw w] 

set board [lindex $argv 0]

puts $fd "##########################################################################"
puts $fd "This is a brief document containing design specific details for : ${board}"
puts $fd "This is auto-generated by Petalinux ref-design builder created @ [clock format [clock seconds] -format {%a %b %d %H:%M:%S %Z %Y}]"
puts $fd "##########################################################################"

set board_part [get_board_parts [current_board_part -quiet]]
if { $board_part != ""} {
  puts $fd "BOARD: $board_part" 
}

set design_name [get_property NAME [get_bd_designs]]
puts $fd "BLOCK DESIGN: $design_name" 

set columns {%40s%30s%15s%50s}
puts $fd [string repeat - 150]
puts $fd [format $columns "MODULE INSTANCE NAME" "IP TYPE" "IP VERSION" "IP"]
puts $fd [string repeat - 150]
foreach ip [get_ips] {
  set catlg_ip [get_ipdefs -all [get_property IPDEF $ip]] 
  puts $fd [format $columns [get_property NAME $ip] [get_property NAME $catlg_ip] [get_property VERSION $catlg_ip] [get_property VLNV $catlg_ip]]
}
close $fd

cd ..
